import Vue from 'vue'
import Vuex from 'vuex'
import {getAdminInfo} from '../api/getData'

Vue.use(Vuex)
const state = {
  adminInfo:{
    avatar: 'default.jpg'
  }
}
const mutations = {
  saveAdminInfo(state,adminInfo){
     console.log(adminInfo);
     this.state.adminInfo = adminInfo
  }
}
const actions = {
 async getAdminData({commit}){
   try{
     const res = await getAdminInfo()
     console.log('getAdminInfo==',res);
     if(res.status == 1){
       commit('saveAdminInfo',res.data)
     } else {
       throw new Error(res.type)
     }
   } catch(err) {
    //  console.log(err);
   }
  }
}

export default new Vuex.Store({
  state,
  mutations,
  actions,
  modules: {
  }
})
